package cn.microven.mindmap.controller.menu;

import cn.microven.mindmap.components.node.RectangleNode;
import cn.microven.mindmap.components.part.BothSideMapPart;
import cn.microven.mindmap.struture.MindMap;
import cn.microven.mindmap.utils.ComponentGetter;
import cn.microven.mindmap.utils.ControllerGetter;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TreeItem;
import javafx.scene.layout.AnchorPane;

import java.net.URL;
import java.util.ResourceBundle;

public class NewFileMenu implements Initializable {

    @FXML
    public AnchorPane newFile;

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        newFile.setOnMouseClicked((mouseEvent -> {
            ControllerGetter.getFileMenu().save();

            MindMap.getInstance().setRoot(new BothSideMapPart(new RectangleNode()));

            TreeItem<String> rt = MindMap.getInstance().getRoot().getTreeItem();
            ComponentGetter.getTreeView().setRoot(rt);
        }));
    }
}
